/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	///  Vector3
	/// module : structs
	/// </summary>
	public class Vector3POD : IPOD 
    {
        public readonly static Func<Vector3POD> FACTORY = () => new Vector3POD();
		public static Func<Vector3POD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public float x;
		/// <summary>
        /// 
        /// </summary>
		public float y;
		/// <summary>
        /// 
        /// </summary>
		public float z;
		
		
		
		/*-- constructors --*/
		public Vector3POD() {}
		public Vector3POD(float x, float y, float z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_float(x);
            _out.Write_float(y);
            _out.Write_float(z);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            x = _in.Read_float();
            if(!_in.HasRemaining()) return;
            y = _in.Read_float();
            if(!_in.HasRemaining()) return;
            z = _in.Read_float();
        }
		
		public Vector3POD Clone() {
            Vector3POD o = DynamicFactory();
            o.x = x;
            o.y = y;
            o.z = z;
            return o;
        }
        
        public void Clear() {
            x = default;
            y = default;
            z = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "Vector3POD [";
			str += "x=";
			str += x;
			str += ", y=";
			str += y;
			str += ", z=";
			str += z;
			str += "]";
			return str;
		}
		
	}
}